package com.alpha.tests;

import static org.junit.Assert.*;

import java.util.ArrayList;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.alpha.bom.Answer;
import com.alpha.bom.Exam;
import com.alpha.bom.PracticeExam;
import com.alpha.bom.Question;
import com.alpha.bom.RealExam;

public class ExamTest {

	private Exam examReal;
	private Exam examPractice;
	@Before
	public void setUp() throws Exception {
		examReal = new RealExam(1001);
		examPractice = new PracticeExam(1002, "Practice Exam");
	}

	@After
	public void tearDown() throws Exception {
		examReal = null;
		examPractice = null;
	}

	@Test
	public void testAddQuestion() {
		//creating a question
		Question q1 = new Question(1, "trueorfalse", "Is this new?", new Answer(1, "True"), "Java");
		ArrayList<Answer> choices = new ArrayList<Answer>();
		choices.add(new Answer(1, "True"));
		choices.add(new Answer(2, "False"));
		q1.setChoices(choices);
		
		//adding the question to Real Exam
		assertEquals("Adding new question to Real Exam", true, examReal.addQuestion(q1));
		
		//adding a previously added question to Real Exam
		assertEquals("Adding a previously added question to Real Exam", false, examReal.addQuestion(q1));
		
		//adding the question to Practice Exam
		assertEquals("Adding a previously added to Practice Exam", true, examPractice.addQuestion(q1));
		
		//adding a previously added question to Practice Exam
		assertEquals("Adding a previously added to Practice Exam", false, examPractice.addQuestion(q1));
	}

}
